package com.bjsxt.ego.common.controller;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.bind.annotation.RequestMapping;

import com.bjsxt.ego.common.util.VerifyCodeUtil;
import com.mysql.fabric.Response;

/**
 * 所有controller的父类
 * @author Administrator
 *
 */
public class BaseController {
	
	/**
	 * 提示信息
	 */
	protected String info;
	
	@RequestMapping("/randImg")
	public String randImg(HttpServletRequest request,HttpServletResponse response) throws IOException
	{
		response.setHeader("Pragma", "No-cache");
		response.setHeader("Cache-Control", "no-cache");
		response.setDateHeader("Expires", 0);
		response.setContentType("image/jpeg");
		
		/**
		 * 生成随机字符串
		 */
		String verifyCode=VerifyCodeUtil.generateVerifyCode(8);
		HttpSession session=request.getSession(true);
		session.setAttribute("rand", verifyCode.toLowerCase());
		
		int w=200,h=80;
		VerifyCodeUtil.outputImage(w, h, response.getOutputStream(), verifyCode);
		
		return null;
	}
}
